﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10.ResourceFile;
using The_Chronicles_of_Asku.Characters;

namespace The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10
{
    class FloorOne
    {
        //FloorSelector selector = new FloorSelector();
        Battle battle = new Battle();
        Skeleton skel = new Skeleton();
        Hero myHero = new Hero();
        Undead zombie = new Undead();
        Necromancer necro = new Necromancer();
        SetMobLevels mobLevel = new SetMobLevels();
        public bool complete = false;

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2241:Provide correct arguments to formatting methods")]
        public void theLevel(Hero myHero, Mob mob)
        {
            Console.WriteLine(FloorOneText.Entrance);
            string answer = Console.ReadLine();
            Console.Clear();

            

            if (answer == "1")
            {

                Console.WriteLine(FloorOneText.Proceed, "/n");

                SkeletonFight(myHero, skel);

                mobLevel.setMobLevelTwo(skel, necro, zombie);

                Console.Clear();

                if (myHero.isAlive == true)
                {
                    Console.WriteLine(FloorOneText.MoveOnFirst, "/n");
                }

                UndeadFight(myHero, zombie);

                Console.Clear();

                UndeadFight(myHero, zombie);

                Console.Clear();
                if (myHero.isAlive == true)
                {
                    Console.WriteLine(FloorOneText.UndeadSetKilled, "/n");
                    string answer2 = Console.ReadLine();


                    if (answer2 == "1")
                    {
                        Console.WriteLine(FloorOneText.FirstRoomLeft, "/n");

                        NecromancerFight(myHero, necro);

                        Console.Clear();

                        NecromancerFight(myHero, necro);

                        Console.Clear();

                        NecromancerFight(myHero, necro);

                        Console.Clear();

                        NecromancerFight(myHero, necro);

                        Console.Clear();

                        if (myHero.isAlive == true)
                        {
                            Console.WriteLine(FloorOneText.FirstRoomLeftFinished, "/n");
                        }
                    }
                }
                if (myHero.isAlive == true)
                {
                    Console.WriteLine(FloorOneText.FirstRoomRight);
                }
                Console.WriteLine();

                SkeletonFight(myHero, skel);

                Console.Clear();

                mobLevel.setMobLevelThree(skel, necro, zombie);

                if (myHero.isAlive == true)
                {
                    Console.WriteLine(FloorOneText.FirstRoomRightSkelKilled);
                    string answer3 = Console.ReadLine();
                    if (answer3 == "2")
                    {
                        Console.WriteLine(FloorOneText.SecondRight);

                        SkeletonFight(myHero, skel);

                        SkeletonFight(myHero, skel);

                        Console.WriteLine(FloorOneText.SecondRightTurnAround);
                        Console.Clear();
                    }
                }
                if (myHero.isAlive == true)
                {
                    Console.WriteLine(FloorOneText.SecondLeft);
                    string exploreAnswer = Console.ReadLine();

                    if (exploreAnswer == "2")
                    {
                        Console.WriteLine(FloorOneText.LastLeftStraight);

                        SkeletonFight(myHero, skel);

                        Console.Clear();

                        UndeadFight(myHero, zombie);

                        Console.Clear();

                        SkeletonFight(myHero, skel);

                        Console.Clear();

                        UndeadFight(myHero, zombie);

                        Console.Clear();
                    }

                    else
                    {
                        if (myHero.isAlive == true)
                        {
                            Console.WriteLine(FloorOneText.LastLeftExplore1);

                            NecromancerFight(myHero, necro);

                            Console.Clear();

                            NecromancerFight(myHero, necro);

                            Console.Clear();

                            NecromancerFight(myHero, necro);

                            Console.Clear();

                            mobLevel.setMobLevelFour(skel, necro, zombie);

                            NecromancerFight(myHero, necro);

                            Console.Clear();

                            if (myHero.isAlive == true)
                            {
                                Console.WriteLine(FloorOneText.LastLeftExplore2);
                            }

                            SkeletonFight(myHero, skel);

                            Console.Clear();

                            SkeletonFight(myHero, skel);

                            Console.Clear();

                            SkeletonFight(myHero, skel);

                            Console.Clear();

                            if (myHero.isAlive == true)
                            {
                                Console.WriteLine(FloorOneText.LastLeftExplore3);
                                myHero.gold = myHero.gold + 50;
                                if (myHero.gold >= myHero.goldCap)
                                {
                                    myHero.gold = myHero.goldCap;
                                }
                            }
                            NecromancerFight(myHero, necro);

                            Console.Clear();
                            if (myHero.isAlive == true)
                            {
                                Console.WriteLine(FloorOneText.LestLeftExploreFinal);
                            }
                            SkeletonFight(myHero, skel);

                            Console.Clear();

                            mobLevel.setMobLevelFive(skel, necro, zombie);

                            UndeadFight(myHero, zombie);

                            Console.Clear();

                            SkeletonFight(myHero, skel);

                            Console.Clear();

                            UndeadFight(myHero, zombie);

                            Console.Clear();
                        }
                    }
                }

                if (myHero.isAlive == true)
                {
                    Console.WriteLine(FloorOneText.End);

                    complete = true;
                }
            }

            else if (answer == "2")
            {
                Console.WriteLine(FloorOneText.TurnAround);
            }

            if (myHero.isAlive == false)
            {
                Console.WriteLine("You are sent back to town where the magicians urgently use spells to revive you. \nBe more careful next time");
                myHero.isAlive = true;
            }

            Console.WriteLine();
            Console.WriteLine("Press Enter to continue", "/n");
            Console.ReadKey();
        }

        private void UndeadFight(Hero myHero, Undead zombie)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, zombie);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            zombie.ResetStats(zombie);
        }

        private void SkeletonFight(Hero myHero, Skeleton skel)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, skel);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            skel.ResetStats(skel);
        }

        private void NecromancerFight(Hero myHero, Necromancer necro)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, necro);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            necro.ResetStats(necro);
        }
    }
}
